import { IpcMainInvokeEvent, ipcMain } from 'electron'
import Ffmpeg from './ffmpeg'
import { selectDirectory } from './directory'
import { CompressOptions } from '../renderer/src/types'

const ffmpeg: Ffmpeg | null = new Ffmpeg()
ipcMain.handle('compress', (event: IpcMainInvokeEvent, options: CompressOptions) => {
  // const compress = new Ffmpeg(event, options)
  // ffmpeg = compress
  ffmpeg.init(event, options).run()
})
ipcMain.handle('selectDirectory', async () => {
  return await selectDirectory()
})
ipcMain.on('stop', () => {
  ffmpeg.stop()
})
